<!DOCTYPE html>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<html class="win-frame">
<head>
<title>组织机构管理-编辑组织机构</title>
<%@include file="/common/head.jsp" %>
<link href="<%=request.getContextPath()%>/static/styles/css/region.css" rel="stylesheet">
<script src="<%=request.getContextPath()%>/static/plugin/JSpinyin/JSpinyin.js"></script>
<script src="<%=request.getContextPath()%>/static/js/region.js"></script>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>组织机构管理</span>
            <span class="split"></span>
            <span>编辑组织机构</span>
        </div>
        <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
    </div>
    <div class="page-title-border"></div>
</div>

<form id="orgForm" method="post">
   <div id="left" style="width:80%;float:left">
     <div class="form-wrapper">
	       <div class="form-cont">
		        <p class="form-cont-title"><span class="field-required">*</span>上级机构名称</p>
		        <input type="hidden" name="id"/> 
				<input type="hidden" name="pCode"/> 
				<input type="hidden" name="code"/> 
				<input type="text" id="pName" class="summer-input" readonly="readonly"/> 
		   </div>
		   
		   <div class="form-cont">
		        <p class="form-cont-title"><span class="field-required">*</span>机构名称</p>
		        <input type="text" id="name" name="name" class="summer-input summer-validatebox" data-validatebox="validType:['required','chsNoSymbol','maxLength[100]']"/>
		   </div>
		   
		   <div class="form-cont">
	          <p class="form-cont-title"><span class="field-required">*</span>行政区划</p>
	          <input type="text" id="regionName" name="regionId" readonly="readonly"  class="summer-input summer-validatebox distance-right" data-validatebox="validType:['required']"/>
	      </div>
	      
	      <div class="form-cont">
	        <p class="form-cont-title">名称简称</p>
	        <input type="text" id="sName" name="sName" class="summer-input summer-validatebox" data-validatebox="validType:['chsNoSymbol','maxLength[50]']"/>
	      </div>
	      
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>机关类型</p>
	        <input type="text" id="type" name="type" class="summer-input summer-validatebox" data-validatebox="validType:['required']"/>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>机构类别</p>
	        <input type="text" id="clazz" name="clazz" class="summer-input summer-validatebox" data-validatebox="validType:['required']"/>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">机构地址</p>
	        <input type="text" id="address" name="address" class="summer-input summer-validatebox" data-validatebox="validType:['maxLength[200]']"/>
	     </div>
	     
	     <div class="form-cont">
	        <p class="form-cont-title">机构电话</p>
	        <input type="text" id="tel" name="tel" class="summer-input summer-validatebox" data-validatebox="validType:['phone']"/>
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title">机构传真</p>
	        <input type="text" id="fax" name="fax" class="summer-input summer-validatebox" data-validatebox="validType:['fax']"/>
	     </div>
	     
	      <div class="form-cont">
	        <p class="form-cont-title"><span class="field-required">*</span>排序号</p>
	        <input type="text" id="orderNo" name="orderNo" class="summer-input summer-validatebox" data-validatebox="validType:['required','betweenInteger[1,100000]']"/>
	     </div>
   </div>
   
   <div class="form-btn-wrapper">
      <a class="btn btn-normal btn-ok" id="saveBtn">保存</a>
   </div>
  </div>
</form>
<script>
    var org;
	$(function() {
		// 初始化机关类型
        initCombobox('type', COMMON_URL.getCode + '?type=T_DM_ORG_TYPE');
		
        // 初始化机构类别
        initCombobox('clazz', COMMON_URL.getCode + '?type=T_DM_ORG_CLAZZ');
        
        //点击查看行政区划
		$('#regionName').region({
            width:700,	//窗口宽度
            height:450,	//窗口高度
            rootId:'0',	//根节点
            level:1//需要拼音分组的层级
		});
        //form表单初始化数据
        var orgData = ${orgData};
		$('#orgForm').form({
			onLoadSuccess: function (data) {
				//上级名称
				$('#pName').val(data['pName'] ? data['pName'] : "无");
				
				$('#regionName').region('setValue',data.regionId);
			}
		}).form('loadDataEdit', {
			data: orgData
		}); 
		
		//保存
		$('#saveBtn').on('click',save);
		
		//返回上级
		$('#goBack').on('click', function () {
			parent.refreshList('${orgVo.code}');
		});
	});
	
	//初始化combobox
    function initCombobox(id, url, async, menuHeight) {
        $('#' + id).combobox({
            valueField: 'code',
            textField: 'name',
            async: async? async: false,
            url: url,
            menuHeight: menuHeight? menuHeight: 'auto'
        });
    }
	
    //保存
	function save() {
		$('#orgForm').form({
			buttons : ['#saveBtn'],
			ajax: {
				url: ORG_CONST_URL.EDIT
			},
			onSubmitSuccess: function (data) {
				$.stip({
 	                type:'ok',//显示类型 有info、 ok、 danger
 	                text: '保存成功！',
 	                onBeforeHide: function () {
 	                    parent.refreshList('${orgVo.code}');
 	               }
             	});
			}
		}).form("submit");
	}
	
	var ORG_CONST_URL = {
	        EDIT: basePath + "/sys/org/edit",
	        LOAD_REGION: basePath + "/sys/inner/regionTree"
	 };
</script>
</body>
</html>
